package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/bus"
	"github.com/streadway/amqp"
	"strconv"
)

func main() {
	rpcShop := new(bus.ShopStatistics).Init()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("bus.log.consumeSuc"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("bus.queue.consumeSuc"), func(msg amqp.Delivery) {
		consumeLogId, _ := strconv.Atoi( string(msg.Body) )

		reply := false
		err := rpcShop.StatisConsume(context.Background(), &consumeLogId, &reply)
		if err != nil {
			utils.Logerr.Printf("消费成功，商家门店数据统计任务执行失败，orderSn:%d, err:%s", consumeLogId, err)
		}
	})

	if err != nil {
		utils.Logerr.Printf("消费成功后的商家门店数据统计任务执行错误, err: %s", err.Error())
	}
}

